Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Untrace entire request #968

Merged
merged 4 commits into from
May 9, 2024

Conversation

robertlaurin
Copy link
Contributor

@robertlaurin robertlaurin commented May 8, 2024

Depends on common 0.21.0 for open-telemetry/opentelemetry-ruby#1634
closes: #962

@robertlaurin robertlaurin changed the title chore: add failing tests fix: Untrace entire request May 8, 2024
return if untraced_request?(request.env)
if untraced_request?(request.env)
ctx = OpenTelemetry::Common::Utilities.untraced
request.env[UNTRACED_CTX_TOKEN] = OpenTelemetry::Context.attach(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need another context (attached) and another token for this? We should add a context = OpenTelemetry::Context.current parameter to extract_remote_context and pass in the untraced context if necessary. I.e.:

parent_context = if untraced_request?(request.env)
    extract_remote_context(request, OpenTelemetry::Common::Utilities.untraced)
  else
    extract_remote_context(request)
  end

Copy link
Contributor

@fbogsany fbogsany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -52,9 +52,12 @@ class EventHandler
# @param [Rack::Response] This is nil in practice
# @return [void]
def on_start(request, _)
return if untraced_request?(request.env)
parent_context = if untraced_request?(request.env)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this relying on start_span to look for the untraced context as opposed to seething the current context to untraced without an active span?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's seeing that it's parent context is untraced so it will create a non recording span, and we have a lot of recording? checks in this instrumentation as is so it seemed like a simpler implementation than what I had in this commit a8548ef

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Thanks again for fixing this!

@robertlaurin
Copy link
Contributor Author

Bumping all the common deps here c8144bc

@robertlaurin robertlaurin merged commit 899970d into open-telemetry:main May 9, 2024
51 checks passed
@robertlaurin robertlaurin deleted the rack-event-untraced branch May 9, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[inst-rack] rack_events + untraced_endpoints will still emit child spans of those endpoint
3 participants